import request from '@/utils/request'

/**
 * 评论接口
 * @method getPage 获取评论列表
 * @method save 保存零零
 * @method remove 删除评论
 * @method getCommentByAttractionId 根据景区获取评论
 * @method approveComment 审核评论
 */
export function useCommentApi() {
  const basePath = '/admin/comment'

  const getPage = (params, data) => {
    return request({
      url: `${basePath}/page`,
      method: 'post',
      params,
      data
    })
  }

  const save = (data) => {
    return request({
      url: `${basePath}/save`,
      method: 'post',
      data
    })
  }

  const remove = (data) => {
    return request({
      url: `${basePath}/delete`,
      method: 'delete',
      data
    })
  }

  const getCommentByAttractionId = (attractionId) => {
    return request({
      url: `${basePath}/get/${attractionId}`,
      method: 'get'
    })
  }

  const approveComment = (data) => {
    return request({
      url: `${basePath}/approve`,
      method: 'put',
      data
    })
  }

  return {
    getPage,
    save,
    remove,
    getCommentByAttractionId,
    approveComment
  }
}
